/**
 * ContactDepartment实体类
 *
 * @author sxf
 * @email sxf02615@163.com
 * @date 2025/1/15
 */
package com.sxf.crm.entity;


import jakarta.persistence.*;
import lombok.Data;

@Entity
@Table(name = "contact_departments")
@Data
public class ContactDepartment {
    @EmbeddedId
    private ContactDepartmentId id;

    @ManyToOne
    @MapsId("contactId")
    @JoinColumn(name = "contact_id")
    private Contact contact;

    @ManyToOne
    @MapsId("departmentId")
    @JoinColumn(name = "department_id")
    private Department department;

    public ContactDepartment() {}

    public ContactDepartment(Contact contact, Department department) {
        this.contact = contact;
        this.department = department;
        this.id = new ContactDepartmentId(contact.getId(), department.getId());
    }

    private Long createAt;
    private Long createUserId;

    private Long updateAt;
    private Long updateUserId;
}
